<template>
  <div class="toast" v-show="isShow">
    {{message}}
  </div>
</template>

<script>
export default {
  name: "Toast",
  props: {
    message: {
      type: String,
      default: ''
    },
    isShow: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    show(message, duration){
      this.show = true
      this.message = message
      setTimeout(() => {
        this.show = false
        this.message = ''
      },duration)
    }
  }
}
</script>

<style scoped>
  .toast{
    position: absolute;
    top: 50%;
    left: 50%;
    padding: 8px 10px;
    transform: translate(-50%, -50%);
    color: #fff;
    background-color: rgba(0,0,0,.3);
  }
</style>
